#include "ESceneObject.h"
#include "eCPP.h"

namespace engine
{

//------------------------------------------------------------
ESceneObject::ESceneObject(const string& sName, MovableObject& object) :
m_pNode( NULL ),
m_sName( sName ),
m_Object( object )
{

}

//------------------------------------------------------------
void ESceneObject::addToOgreScene( SceneManager& sceneManager )
{
  cASSERT( m_pNode == NULL );
  m_pNode = sceneManager.getRootSceneNode()->createChildSceneNode( m_sName + "Node" );
  cASSERT( m_pNode != NULL );
  m_pNode->attachObject( &m_Object );
}

//------------------------------------------------------------
/// \todo verify if removeChild is the correct method to call
void ESceneObject::removeFromOgreScene( SceneManager& sceneManager )
{
  cASSERT( m_pNode != NULL );
  m_pNode->detachObject( &m_Object );
  sceneManager.getRootSceneNode()->removeChild( m_pNode );
  m_pNode = NULL;
}

} // end namespace